package xin.clips;

import com.alibaba.druid.support.http.StatViewServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

import java.util.HashMap;
import java.util.Map;

/**
 * 启动程序
 * 
 * @author yuanzy
 */
@MapperScan("xin.clips.system.mapper")
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class ClipsApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(ClipsApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  芜湖工业互联网项目启动成功   ლ(´ڡ`ლ)ﾞ  ");
    }

    @Bean
    public ServletRegistrationBean statViewServlet() {
        final ServletRegistrationBean<StatViewServlet> servletRegistrationBean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*");
        // 配置druid参数
        Map<String, String> initParams = new HashMap<>(16);
        // 默认访问用户密码 admin:admin
        initParams.put("loginUsername", "admin");
        initParams.put("loginPassword", "qwer1234!@#$");
        // 允许访问的ip
        initParams.put("allow", "127.0.0.1");
        // 黑名单ip，优先级比allow配置高
        initParams.put("deny", "");
        servletRegistrationBean.setInitParameters(initParams);
        return servletRegistrationBean;
    }
}